package erp.education.server.db.implementation.finance;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import erp.education.server.db.entites.finance.FeeHeads;
import erp.education.server.db.implementation.common.BaseDAO;
import erp.education.server.db.interfaces.finance.FeeHeadsDAOI;

@Component("feeHeadDao")
public class FeeHeadDAO extends BaseDAO implements FeeHeadsDAOI {

	@Override
	public FeeHeads getFeeHead(Long feeCode) {
		// TODO Auto-generated method stub
		FeeHeads feeHead = null;
		Map params = new HashMap();

		params.put("feeCode", feeCode);

		feeHead = (FeeHeads) getSingleResult(
				"select feeHead from FeeHeads feeHead where feeHead.feeCode=:feeCode",
				params);

		return feeHead;
	}

	@Override
	public FeeHeads getFeeHead(String feeHeadName) {
		// TODO Auto-generated method stub
		FeeHeads feeHead = null;
		Map params = new HashMap();

		params.put("feeHeadName", feeHeadName);

		feeHead = (FeeHeads) getSingleResult(
				"select feeHead from FeeHeads feeHead where feeHead.feeName=:feeHeadName",
				params);

		return feeHead;
	}

	@Override
	public List<Object[]> getFeeHeads() {
		// TODO Auto-generated method stub
		List<Object[]> feeGroups = null;
		Map params = new HashMap();
		feeGroups = (List<Object[]>) getResultList(
				"select feeHead.feeCode,feeHead.feeType,feeGroup.groupId,feeGroup.groupName,feeHead.feeName,feeHead.feeRefundable,feeHead.taxExempted from FeeGroup feeGroup,FeeHeads feeHead where feeHead.feeGroupId=feeGroup.groupId ",
				params);
		return feeGroups;

	}
}
